package com.huawei.appmarket.service.settings.view.widget;

import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.View;
import android.view.ViewGroup.OnHierarchyChangeListener;
import android.view.accessibility.AccessibilityEvent;
import android.view.accessibility.AccessibilityNodeInfo;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import java.util.concurrent.atomic.AtomicInteger;
import o.ehg;

public class VerticalRadioViewGroup extends LinearLayout {
    private static final AtomicInteger ˏ = new AtomicInteger(1);
    private a ʼ;
    private int ˊ = -1;
    private ehg ˋ;
    private boolean ˎ = false;
    private OnCheckedChangeListener ॱ;

    public static class LayoutParams extends android.widget.LinearLayout.LayoutParams {
        public LayoutParams(Context context, AttributeSet attributeSet) {
            super(context, attributeSet);
        }

        public LayoutParams(int i, int i2) {
            super(i, i2);
        }

        protected void setBaseAttributes(TypedArray typedArray, int i, int i2) {
            if (typedArray.hasValue(i)) {
                this.width = typedArray.getLayoutDimension(i, "layout_width");
            } else {
                this.width = -2;
            }
            if (typedArray.hasValue(i2)) {
                this.height = typedArray.getLayoutDimension(i2, "layout_height");
            } else {
                this.height = -2;
            }
        }
    }

    class a implements OnHierarchyChangeListener {
        final /* synthetic */ VerticalRadioViewGroup ˏ;
        private OnHierarchyChangeListener ॱ;

        private a(VerticalRadioViewGroup verticalRadioViewGroup) {
            this.ˏ = verticalRadioViewGroup;
        }

        public void onChildViewAdded(View view, View view2) {
            if (view == this.ˏ && (view2 instanceof RadioButton)) {
                ˋ(view2);
            } else if (view == this.ˏ && (view2 instanceof VerticalRadioView)) {
                ˋ(((VerticalRadioView) view2).ˊ());
            }
            if (this.ॱ != null) {
                this.ॱ.onChildViewAdded(view, view2);
            }
        }

        private void ˋ(View view) {
            if (view.getId() == -1) {
                view.setId(View.generateViewId());
            }
            ((RadioButton) view).setOnCheckedChangeListener(this.ˏ.ॱ);
        }

        public void onChildViewRemoved(View view, View view2) {
            if (view == this.ˏ && (view2 instanceof RadioButton)) {
                ((RadioButton) view2).setOnCheckedChangeListener(null);
            } else if (view == this.ˏ && (view2 instanceof VerticalRadioView)) {
                ((VerticalRadioView) view2).ˊ().setOnCheckedChangeListener(null);
            }
            if (this.ॱ != null) {
                this.ॱ.onChildViewRemoved(view, view2);
            }
        }
    }

    class d implements OnCheckedChangeListener {
        final /* synthetic */ VerticalRadioViewGroup ˎ;

        private d(VerticalRadioViewGroup verticalRadioViewGroup) {
            this.ˎ = verticalRadioViewGroup;
        }

        public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
            if (!this.ˎ.ˎ) {
                this.ˎ.ˎ = true;
                if (this.ˎ.ˊ != -1) {
                    this.ˎ.ˊ(this.ˎ.ˊ, false);
                }
                this.ˎ.ˎ = false;
                this.ˎ.ˋ(compoundButton.getId());
            }
        }
    }

    public /* synthetic */ android.view.ViewGroup.LayoutParams generateLayoutParams(AttributeSet attributeSet) {
        return ˋ(attributeSet);
    }

    public /* synthetic */ android.widget.LinearLayout.LayoutParams m7generateLayoutParams(AttributeSet attributeSet) {
        return ˋ(attributeSet);
    }

    public VerticalRadioViewGroup(Context context) {
        super(context);
        setOrientation(1);
        ˋ();
    }

    public VerticalRadioViewGroup(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ();
    }

    private void ˋ() {
        this.ॱ = new d();
        this.ʼ = new a();
        super.setOnHierarchyChangeListener(this.ʼ);
    }

    public void setOnHierarchyChangeListener(OnHierarchyChangeListener onHierarchyChangeListener) {
        this.ʼ.ॱ = onHierarchyChangeListener;
    }

    protected void onFinishInflate() {
        super.onFinishInflate();
        if (this.ˊ != -1) {
            this.ˎ = true;
            ˊ(this.ˊ, true);
            this.ˎ = false;
            ˋ(this.ˊ);
        }
    }

    public void addView(View view, int i, android.view.ViewGroup.LayoutParams layoutParams) {
        if (view instanceof RadioButton) {
            ˎ((RadioButton) view);
        } else if (view instanceof VerticalRadioView) {
            ˎ(((VerticalRadioView) view).ˊ());
        }
        super.addView(view, i, layoutParams);
    }

    private void ˎ(RadioButton radioButton) {
        if (radioButton.isChecked()) {
            this.ˎ = true;
            if (this.ˊ != -1) {
                ˊ(this.ˊ, false);
            }
            this.ˎ = false;
            ˋ(radioButton.getId());
        }
    }

    public void ˎ(int i) {
        if (i == -1 || i != this.ˊ) {
            if (this.ˊ != -1) {
                ˊ(this.ˊ, false);
            }
            if (i != -1) {
                ˊ(i, true);
            }
            ˋ(i);
        }
    }

    private void ˋ(int i) {
        this.ˊ = i;
        if (this.ˋ != null) {
            this.ˋ.ॱ(this, this.ˊ);
        }
    }

    private void ˊ(int i, boolean z) {
        View findViewById = findViewById(i);
        if (findViewById != null && (findViewById instanceof RadioButton)) {
            ((RadioButton) findViewById).setChecked(z);
        }
    }

    public int ˏ() {
        return this.ˊ;
    }

    public void setOnCheckedChangeListener(ehg o_ehg) {
        this.ˋ = o_ehg;
    }

    public LayoutParams ˋ(AttributeSet attributeSet) {
        return new LayoutParams(getContext(), attributeSet);
    }

    protected boolean checkLayoutParams(android.view.ViewGroup.LayoutParams layoutParams) {
        return layoutParams instanceof LayoutParams;
    }

    protected android.widget.LinearLayout.LayoutParams generateDefaultLayoutParams() {
        return new LayoutParams(-2, -2);
    }

    public void onInitializeAccessibilityEvent(AccessibilityEvent accessibilityEvent) {
        super.onInitializeAccessibilityEvent(accessibilityEvent);
        accessibilityEvent.setClassName(RadioGroup.class.getName());
    }

    public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo accessibilityNodeInfo) {
        super.onInitializeAccessibilityNodeInfo(accessibilityNodeInfo);
        accessibilityNodeInfo.setClassName(RadioGroup.class.getName());
    }
}
